layui.use(['table', 'admin', 'ax', 'func','tree','ztree','layer','form'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    //var admin = layui.admin;
    var func = layui.func;
    var tree = layui.tree;
    var $ZTree = layui.ztree;
    var layer = layui.layer;
    var form = layui.form;


    var ProjectWjc = {
        tableId: "gcgWsjdTable"
    };

    /**
     * 初始化表格的列
     */
    ProjectWjc.initColumn = function () {
        return [[
            {align: 'center', type: "numbers", title: '序号', fixed: 'left'},
            {field: 'id', hide: true, title: ''},
            {field: 'name', sort: true, title: '门店',width: 300},
            {field: 'kfName', title: '开发人员'},
            {field: 'yyjlName', title: '营运经理'},
            {field: 'cjriqi',title: '建店日期'},
            {field: 'yjkyriqi',title: '预计开业日期'},
            {field: 'kyriqi', title: '开业日期'},

        ]];
    };

    /**
     * 点击查询按钮
     */
    ProjectWjc.search = function () {
        var queryData = {};

        queryData['name'] = $('#name').val();

        table.reload(ProjectWjc.tableId, {
            where: queryData, page: {curr: 1}
        });
    };


    /**
     * 导出excel按钮
     */
    ProjectWjc.exportExcel = function () {
        //获取导出的数据
        var ajax = new $ax(Feng.ctxPath + "/project/wjcList");
        var result = ajax.start();
        // alert(result);
        table.exportFile(tableResult.config.id, result, 'xls');
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + ProjectWjc.tableId,
        url: Feng.ctxPath + '/project/projectWjcList',
        page: true,
        height: "full-59",
        cellMinWidth: 100,
        limit: 20,
        cols: ProjectWjc.initColumn(),
    });

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        ProjectWjc.search();
    });

    // 导出excel
    $('#btnExp').click(function () {
        ProjectWjc.exportExcel();
    });


});
